home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / DIZZY / SRC / DIZZY.H < prev    next >
Text File  |  1991-01-03  |  6KB  |  149 lines

  1. /*
  2. >>    Dizzy 0.0    Dizzy.h
  3. >>
  4. >>    A digital circuit simulator & design program for the X Window System
  5. >>
  6. >>    Copyright 1990 Juri Munkki, all rights reserved
  7. >>
  8. >>    Please read the included file called "DizzyDoc" for information on
  9. >>    what your rights are concerning this product.
  10. */
  11.  
  12. /*    If this program is compiled with Think C, it's probably on a Macintosh. */
  13. #ifdef    THINK_C
  14. #define MACINTOSH
  15. #endif
  16.  
  17. #ifdef    MAIN_PROGRAM
  18. #define GLOBAL
  19. #else
  20. #define GLOBAL    extern
  21. #endif
  22.  
  23. #ifdef    MACINTOSH
  24. #define HILITEMODE        asm {    BCLR    #7,0x938    }
  25. #define PenXor()        PenMode(patXor)
  26. #define PenCopy()        PenMode(patCopy)
  27. #define PenGray()        PenPat(gray)
  28. #define PenBlack()        PenPat(black)
  29. #define LCENTERING    2
  30. #define    MAXFILENAME    256                        /*    Maximum length of a file name for Mac.    */
  31. #else
  32. #include "macstuff.h"
  33. #define    MAXFILENAME    2048                        /*    Maximum length of a path for unix.    */
  34. #define LCENTERING    0
  35. #endif
  36.  
  37. #include "elementdefs.h"
  38.  
  39. typedef struct
  40. {
  41.     long    Chip;        /*    Usually offset to the output element    */
  42.     int     Pin;        /*    Pin number to use for input             */
  43.  
  44. }    Input;
  45.  
  46. typedef struct
  47. {
  48.     int     Data;        /*    Output data bits from this pin.             */
  49.     int     RefCount;    /*    Number of references to this output pin.    */
  50. }    Output;
  51.  
  52. typedef struct
  53. {    
  54.     long    PrevLength; /*    Length of previous object (or 0, if first)    */
  55.     long    Length;     /*    Lenght of this object (or 0, if last)        */
  56.     long    Type;        /*    Object type magic number (4 chars, really)    */
  57.     int     Number;     /*    Identifying number of object                */
  58.     int     Flags;        /*    Flags: private and public.                    */
  59.     int     PrivData;    /*    Private data for element.                    */
  60.     Rect    Body;        /*    Rectangle containing main body of element    */
  61.     Rect    InRect;     /*    Rectangle containing inputs of element        */
  62.     Rect    OutRect;    /*    Rectangle containing outputs of element     */
  63.     int     Outputs;    /*    Number of outputs                            */
  64.     int     Inputs;     /*    Number of inputs                            */
  65.     Output    Out[1];     /*    Outputs                                     */    
  66. }    Element;
  67.  
  68.  
  69. typedef struct
  70. {
  71.     long    First;        /*    Offset to first element                 */
  72.     long    Last;        /*    Offset to last element                    */
  73.     int     XOrig;        /*    X origin (screen coordinates)            */
  74.     int     YOrig;        /*    Y origin                                */
  75.     int     TitleWidth; /*    Width of title in pixels.                */
  76.     int     TitleLen;    /*    Length of title in characters.            */
  77.     int     PathLen;    /*    Length of whole filename/path in chars. */
  78. }    TableHeader;
  79.  
  80. typedef struct
  81. {                        /*    Function is negative, if NOT is also on.*/
  82.     int     Function;    /*    1..19. 1 is NOT, 19 is zapper tool.     */
  83.     Rect    Prime;        /*    Rectangle of selected button.            */
  84.     Rect    Secondary;    /*    If Function<0, invert this rect as well.*/
  85. }    ToolSelection;
  86.  
  87. #define MOUSE_BUTTONS    3        /*    Number of mouse button functions    */
  88.  
  89. /*    User interface variables:    */
  90. #ifdef    MACINTOSH
  91. GLOBAL    WindowPtr        MyWind;         /*    We use just one window.             */
  92. GLOBAL    EventRecord     MyEvent;        /*    Globally used event record.         */
  93. GLOBAL    PicHandle        ToolP,MenuP;    /*    Handles to pictures of "menus"        */
  94. GLOBAL    BitMap            ButtonBits;     /*    Bitmap to misc stuff.                */
  95. GLOBAL    RgnHandle        BackRegion;     /*    Gray area in our window.            */
  96. #endif
  97. GLOBAL    Rect            PortRect;        /*    Rectangle containing our window     */
  98. GLOBAL    int             QuitNow;        /*    Exit program, if this is true.        */
  99. GLOBAL    Rect            ToolR,MenuR;    /*    Rectangle containing menus.         */
  100. GLOBAL    Rect            MenuHilite;     /*    Contains menu item being executed.    */
  101. GLOBAL    ToolSelection    ToolButtons[MOUSE_BUTTONS]; /*    Tool functions.         */
  102. GLOBAL    ToolSelection    ToolLocks[MOUSE_BUTTONS];    /*    Locked tools.            */
  103. GLOBAL    int             InputSelector;    /*    Number of input pins in AND_s etc.    */
  104. GLOBAL    Rect            InputFrame;     /*    Frame around input selector.        */
  105. GLOBAL    Rect            EditR,EditOutline;    /*    Editing area rectangles.        */
  106. GLOBAL    Rect            EditClipper;    /*    Editing area in circuit coordinates.*/
  107. GLOBAL    int             ConnectorFrames;/*    true=>connectors are always framed. */
  108. GLOBAL    Rect            NilRect;        /*    left=0,top=0,right=0,bottom=0        */
  109. GLOBAL    int             SplashVisible;    /*    Is splash screen is visible?        */
  110.  
  111. /*    Simulation globals:         */
  112. #ifdef    MACINTOSH
  113. GLOBAL    Handle            SimHandle;        /*    Memory spool for chips.             */
  114. #endif
  115. GLOBAL    Ptr             SimPtr;         /*    Pointer to memory spool.            */
  116. GLOBAL    long            SimSize;        /*    Size of allocated memory spool.     */
  117. GLOBAL    long            SimEnd;         /*    First unused byte of memory spool.    */
  118. GLOBAL    int             SimLevel;        /*    Subchip recursion level counter.    */
  119. GLOBAL    int             SimTimer;        /*    A clock for the clock component.    */
  120. GLOBAL    long            SimSpeed;        /*    Time between two simulation steps.    */
  121. GLOBAL    TableHeader     *CurHeader;     /*    Pointer to currently simulated header.*/
  122. GLOBAL    TableHeader     *MainHeader;    /*    Pointer to top level header.        */
  123. GLOBAL    Ptr             SimBase;        /*    Start of current level components.    */
  124.  
  125. /*    File globals:                    */
  126. #ifdef    MACINTOSH
  127. GLOBAL    SFReply     NameOfOpenFile; /*    Contains info needed to access the file.    */
  128. #endif
  129. GLOBAL    int         FileIsNamed;    /*    True, if file has been previously named.    */
  130.  
  131.  
  132. #define RAMCHUNK        32768L        /*    Amount of memory to allocate with one call. */
  133.  
  134. /*    Simulation constants            */
  135. #define NEWVALUE            1        /*    Output & 1 == new value. May be invalid.    */
  136. #define CURRENTVALUE        2        /*    Output & 2 == current value. Always valid.    */
  137. #define OLDVALUE            4        /*    Output & 4 == old value for edge detection. */
  138.  
  139. /*    Flag bits                        */
  140. #define INVERTED            1        /*    Output pin #1 is inverted as in NAND.        */
  141. #define RESOLVED            2        /*    This element has already been simulated.    */
  142. #define DISPLAYEDVALUE        4        /*    Value currently displayed on screen. OUTP_    */
  143.  
  144. /*    Misc. defines                    */
  145. #define MAX_WIRES            100     /*    Max number of wires to rubberband at once.    */
  146. #define MAX_ZAPS            5        /*    Number of zaps to do before garbage collect.*/
  147.  
  148. #include    "protos.h"                /*    Include prototypes for functions.            */
  149.